package com.TTBook.utils;

import java.util.HashMap;
import java.util.Map;

public class BookBaseServiceException extends BookBaseException{
	/**
	 * 错误代码
	 */
	private String errorCode;
	/**
	 * 自定义错误数�?
	 */
	private Map<String,String> errorData = new HashMap<String,String>();
	/**
	 * 是否应该显示此数据信息给�?��用户
	 */
	private boolean shouldReportToEndUser;
	
	public String getErrorCode()
	{
		return errorCode;
	}

	public void setErrorCode(String errorCode)
	{
		this.errorCode = errorCode;
	}

	public Map<String, String> getErrorData()
	{
		return errorData;
	}

	public void setErrorData(Map<String, String> errorData)
	{
		this.errorData = errorData;
	}

	public boolean isShouldReportToEndUser()
	{
		return shouldReportToEndUser;
	}

	public void setShouldReportToEndUser(boolean shouldReportToEndUser)
	{
		this.shouldReportToEndUser = shouldReportToEndUser;
	}

	public BookBaseServiceException(Throwable e)
	{
		super(e);
	}

	public BookBaseServiceException(String message)
	{
		super("error.unknown", message);
	}

	/**
	 * @param message
	 */
	public BookBaseServiceException(String code, String message)
	{
		super(code, message);
	}

	public BookBaseServiceException(final String code, final String message,
			final Object[] args)
	{
		super(code, message, args);
	}

	public BookBaseServiceException(final String code, final String message,
			final Object[] args, final Throwable cause)
	{
		super(code, message, args, cause);
	}
	
	public BookBaseServiceException(final
			String errorCode,final String message,final Map<String,String> futherErrorData)
	{
		this(true,errorCode,message,futherErrorData);
	}
	
	public BookBaseServiceException(final boolean shouldReportToEndUser,final
			String errorCode,final String message,final Map<String,String> futherErrorData)
	{
		super("error.unknown", message);
		this.shouldReportToEndUser = shouldReportToEndUser;
		this.errorCode = errorCode;
		Object[] keys = futherErrorData.keySet().toArray();
		for(int i=0; i!=keys.length; i++)
		{
			String value = futherErrorData.get(keys[i].toString());
			errorData.put(keys[i].toString(),value);
		}
	}

	/**
	 * serialVersionUID
	 */
	private static final long serialVersionUID = 1L;
}
